using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class VFXComtroll : MonoBehaviour
{
    public GameObject objectToShow; // 要显示的对象
    public string playerTag = "Player"; // 玩家标签，默认为 "Player"

    private void Start()
    {
        if (objectToShow != null)
        {
            objectToShow.SetActive(false); // 确保初始状态下对象是隐藏的
        }
    }

    private void OnCollisionEnter(Collision collision)
    {
        Debug.Log("Collision detected with: " + collision.gameObject.name); // 输出碰撞对象名称
        if (collision.gameObject.CompareTag(playerTag)) // 检测玩家标签
        {
            Debug.Log("Player detected!"); // 确认标签检测成功
            if (objectToShow != null)
            {
                objectToShow.SetActive(true); // 显示对象
                Debug.Log("Object shown: " + objectToShow.name); // 确认对象已显示
            }
            else
            {
                Debug.LogWarning("objectToShow is not assigned in the inspector!");
            }
        }
        else
        {
            Debug.Log("Object does not have the Player tag.");
        }
    }
}
